<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="Admin.Admin" %>
<%@ page import="Page.Page"   %>
<%@ page import="java.util.*"  %>
<%@ page import="Admin.AdminDeal"%>
<script type="text/javascript" language="javaScript">

	function del(url){
	if(confirm("确定要删除？")){
		window.location.href = ("AdminDelete.jsp?DealID="+url);
	}
	//document.form1.action("DeleTopicServlet?topicID="+url);
	}
	function modify(url){
	window.location.href = ("AdminModify.jsp?DealID="+url);
	//document.form1.action("AdminModify.jsp?DealID="+url);
	}

</script>
<%
   //从数据库中去出结果集
   int currentRecord = 0;
   String DealID="";
   int flag=0;
   String sql="";
   int k=0;
   int k1=0;
   Page pager=new Page();
   AdminDeal db=new AdminDeal();
   ArrayList<Admin> result =db.AdminShow(); 
   pager.setPageSize(6);
   pager.setTotalRecord(result.size());
   pager.setTotalPage(result.size(),pager.getPageSize());
   //计算并设置分页的参数
   if(request.getParameter("currentRecord")!=null)
   {   
       currentRecord = Integer.parseInt(request.getParameter("currentRecord"));
       pager.setCurrentRecord(currentRecord);
       pager.setCurrentPage(currentRecord,pager.getPageSize());
   }
   //从结果集中取出当前页面要显示的子集
   List<Admin> subResult = null;
   if(currentRecord == 0)
   {
       if(currentRecord+pager.getPageSize()<=result.size())
       {
            subResult = result.subList(0,pager.getPageSize());
       	
       }
       else
       {
       	   	subResult = result.subList(0,result.size());
       }
   
   }
   else if(pager.getCurrentRecord()+pager.getPageSize()<result.size())
       subResult = result.subList(pager.getCurrentRecord(),pager.getCurrentRecord

()+pager.getPageSize());
   else
       subResult = result.subList(pager.getCurrentRecord(),result.size());
 %>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
  </head>
<body>
<div class="app_top"><span class="app_top_font">当前位置：东师格子铺——>管理员查看</span></div>
<div class="adminLook"> <table width="999" border="0">
  <tr>
    <td width="114" height="36"><img src="../images/adminLook_03.png" width="70" height="15" /></td>
    <td width="125"><img src="../images/adminLook_05.png" width="73" height="15" /></td>
    <td width="132"><img src="../images/adminLook_07.png" width="56" height="15" /></td>
    <td width="119"><img src="../images/adminLook_09.png" width="56" height="15" /></td>
    <td width="104"><img src="../images/adminLook_11.png" width="28" height="15" /></td>
    <td width="91"><img src="../images/adminLook_13.png" width="28" height="15" /></td>
    <td width="101"><img src="../images/adminLook_15.png" width="28" height="15" /></td>
    <td width="179"><img src="../images/adminLook_17.png" width="28" height="15" /></td>
  </tr>
     		
   		<%
   			 if(subResult.isEmpty()==false)
		       {
		             for(int i=0;i<subResult.size();i++)
		             {
		            	 Admin Admin = subResult.get(i);
		            	 AdminDeal d=new AdminDeal();
						 out.print("<tr>");
		                 out.print("<td>"+Admin.getAdmID()+"</td>");
		                 out.print("<td>"+Admin.getAdmKey()+"</td>");
		                 out.print("<td>"+Admin.getAdmTrueName()+"</td>");
		                 out.print("<td>"+Admin.getAdmBirthday()+"</td>");
		                 out.print("<td>"+d.turn(Admin.getAdmSex())+"</td>");
		                 out.print("<td>"+Admin.getAdmTel()+"</td>");
		                 out.print("<td>"+Admin.getAdmEmail()+"</td>");
		                 if(Admin.getAdmID().trim().equals("admin"))
		                 {
		                	 %>
		                	 <td><input name="bianji" type="button" class="bianji"  onclick="modify('<%=Admin.getAdmID() %>')"></input></td></tr>
		                	 <% 
		               
		                 }
		                 else
		                 {
		                	 %>
		                 	 <td><input type= "button" class="bianji"  onclick="modify('<%=Admin.getAdmID()%>')"></input>
			                 <input type= "button" class="bianji2" onclick="del('<%=Admin.getAdmID()%>')"></input></td>
			                 </tr>
			                 <%   
		                 }
		                
		             }
		        }
   		 %>	
</table>
</div>
<div class="bus_bottom_page">   	<span><font size="2">总<%=pager.getTotalRecord()%>条记录|总<%=pager.getTotalPage()%>页|当

前<%=pager.getCurrentPage()+1%>页|每页<%=pager.getPageSize()%>条|
<% 
    //如果已经到了首页就去掉前一页的链接
    if(pager.getCurrentRecord()-pager.getPageSize()<0)
        out.println("首页|");
    else
    //上一页就是把当前记录位置减去一页显示记录的条数
        out.print("<a href='AdminShow.jsp?currentRecord="+(pager.getCurrentRecord()-

pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>上一页</a>|");
    //如果到了尾页就去掉下一页的链接
    if(pager.getCurrentRecord()+pager.getPageSize()>=pager.getTotalRecord())
        out.println("尾页");
    else
    //下一页就是把当前记录位置加上一页显示记录的条数
        out.print("<a href='AdminShow.jsp?currentRecord="+(pager.getCurrentRecord

()+pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>下一页</a>|"); 
%>
</font></span></div>
</body>
</html>
